/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejb;

import javax.annotation.Resource;
import javax.annotation.security.DeclareRoles;
import javax.annotation.security.DenyAll;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;

/**
 *
 * @author usuario
 */
@Stateless
@DeclareRoles({"ROL_ADMIN","ROL_USUARIO"})
public class BeanSeguro implements BeanSeguroLocal,BeanSeguroRemoto {
    @Resource
    SessionContext ctx;
    
    @Override
    @PermitAll
    public void metodoPublico() {
         System.out.println("metodoPublico -->"+ctx.getCallerPrincipal().getName());    
    }

    @Override
    @DenyAll
    public void denegarTodo() {
        System.out.println("denegarTodo -->"+ctx.getCallerPrincipal().getName());  
    }

    @Override
    @RolesAllowed( {"ROL_ADMIN"} )
    public void permitirRol() {
        System.out.println("permitirRol -->"+ctx.getCallerPrincipal().getName());  
    }

    
    
}
